package com.quanxiaoha.weblog.web.controller.record;

import com.quanxiaoha.weblog.common.aspect.ApiOperationLog;
import com.quanxiaoha.weblog.common.domain.query.*;
import com.quanxiaoha.weblog.common.domain.vo.*;
import com.quanxiaoha.weblog.common.domain.entity.ScheduleReward;
import com.quanxiaoha.weblog.common.service.IScheduleRewardService;
import com.quanxiaoha.weblog.common.service.ScheduleCountService;
import com.quanxiaoha.weblog.common.service.impl.DeepSeekService;
import com.quanxiaoha.weblog.common.utils.Response;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;


/**
 * @author: 犬小哈
 * @url: www.quanxiaoha.com
 * @date: 2023-08-10 10:34
 * @description: TODO
 **/
@RestController
@Slf4j
@Api(tags = "推荐")
@RequestMapping("/todo")
public class ScheduleCountController {


    @Autowired
    private ScheduleCountService scheduleCountService;

    @Autowired
    private IScheduleRewardService scheduleRewardService;

    @PostMapping("/recommend")
    @ApiOperationLog(description = "推荐列表")
    @ApiOperation(value = "推荐列表")
    public Response recommend(@RequestBody CountQuery query) {

        List<CountVo> recommend = scheduleCountService.recommend(query);
        return Response.success(recommend);
    }

    @PostMapping("/reverseRecommend")
    @ApiOperationLog(description = "逆向推荐列表")
    @ApiOperation(value = "逆向推荐列表")
    public Response reverseRecommend(@RequestBody CountQuery query) {

        List<CountVo> recommend = scheduleCountService.reverseRecommend(query);
        return Response.success(recommend);
    }

    @PostMapping("/homeDetails")
    @ApiOperationLog(description = "首页明细")
    @ApiOperation(value = "首页明细")
    public Response homeDetails(@RequestBody @Validated CensusQuery query) {

        HomeDetailVo homeDetail = scheduleCountService.homeDetails(query);
        return Response.success(homeDetail);
    }

    @PostMapping("/homeHeader")
    @ApiOperationLog(description = "首页头部")
    @ApiOperation(value = "首页头部")
    public Response homeHeader(@RequestBody @Validated CensusQuery query) {

        HomeHeaderVo homeHeader = scheduleCountService.homeHeader(query);
        return Response.success(homeHeader);
    }

    @GetMapping("/getPoint")
    @ApiOperationLog(description = "获取积分")
    @ApiOperation(value = "获取积分")
    public Response getPoint(@RequestParam("tagId") Integer tagId) {

        try {
            PointVo point = scheduleRewardService.getPoint(tagId);
            return Response.success(point);
        }catch (Exception e) {
            return Response.fail(e.getMessage());
        }
    }

    @GetMapping("/getDetail")
    @ApiOperationLog(description = "获取详情")
    @ApiOperation(value = "获取详情")
    public Response getDetail() {

        try {
            ScheduleReward detail = scheduleRewardService.getDetail();
            return Response.success(detail);
        }catch (Exception e) {
            return Response.fail(e.getMessage());
        }
    }

    @PostMapping("/consume")
    @ApiOperationLog(description = "消费")
    @ApiOperation(value = "消费")
    public Response consume(@RequestBody RewardQuery query) {

        try {
            scheduleRewardService.consume(query);
            return Response.success();
        }catch (Exception e) {
            return Response.fail(e.getMessage());
        }
    }


    @GetMapping("/init")
    @ApiOperationLog(description = "初始化日期")
    @ApiOperation(value = "初始化日期")
    public Response init() {

        scheduleRewardService.init();
        return Response.success();
    }



}
